import { useEffect, useState } from "react";
import TitlePublic from "@/components/title-public/index";
import { getNewsCenterApi } from "@/api/news-center/index";
import "./index.scss";
import { mockData } from "../mock-data";
import { useNavigate } from "react-router-dom";
import HtmlContent from "@/components/html-content/index";

// 使用组件
const htmlString = "<p>这是<b>HTML</b>片段</p>";
export default function EnterpriseNews() {
  const [industryList, setIndustryList] = useState([]);
  const navigate = useNavigate();
  const getNewsCenter = async () => {
    const res = await getNewsCenterApi({
      page: 1,
      pageSize: 100,
    });

    setIndustryList(res.data.list);
  };

  useEffect(() => {
    // getNewsCenter();
  }, []);

  const handleToDetai = (id) => {
    navigate(`/news-center/company-news/company-news-detail/${id}`);
  };
  return (
    <div>
      <TitlePublic englishTitle="Company News" chineseTitle="公司动态" />
      <ul className="company-news-ul">
        {mockData.map((item) => {
          return (
            <li
              key={item.title}
              className="company-news-item"
              onClick={() => handleToDetai(item.id)}
            >
              <div className="left">
                <img src={item.headerImg} alt="" className="header-img" />
              </div>
              <div className="right">
                <div className="title">{item.title}</div>
                <HtmlContent html={item.shortNews} />
                <div className="time">{item.date}</div>
              </div>
            </li>
          );
        })}
      </ul>
    </div>
  );
}
